<%--
  Created by IntelliJ IDEA.
  User: Mahesha Kalpanie
  Date: 8/26/12
  Time: 5:16 PM
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript">

    $(document).ready(function () {
        changeHectareKml();
        $("#saveButton").hide();

        var kmlString = '<s:property value="land.kmlString"/>';
        if (kmlString != null && kmlString.length != 0) {

            var latLonStr = '<s:property value="latLonStr"/>';
            var latLon = "";
            if (latLonStr.length > 0) {
                latLon = latLonStr.split(",");
                calculateArea(latLon);
            }

            $("#saveButton").show();
        }
    });

    function calculateArea(AList) {
        if (AList != null) {
            //  var AList = latLonList;
            var points = new Array();

            var Alenth = AList.length;
            var j = 0;
            for (i = 0; i < Alenth - 2; i++) {
                //points[j] = new google.maps.LatLng(AList[i++], AList[i]);
                points[j++] = new google.maps.LatLng(Number(AList[i + 1]), Number(AList[i]));
                i++;
                measureAdd(points[j - 1]);
            }

            area = google.maps.geometry.spherical.computeArea(points);
            $('#kmlArea').val(area);
            changeHectareKml();

        }
    }

</script>
<h2><s:label value="%{getText('geo_info.label')}"/></h2>

<div align="left">
    <s:actionmessage cssStyle="color:green"/>
</div>
<table>
    <tr id="kmlDocumentUpload">
        <td colspan="4">
            <s:form action="getKMLDataSubDivide" method="post" enctype="multipart/form-data">
                <s:actionerror cssStyle="color:red"/>
                <s:label value="%{getText('attach_kml_file.label')}"/>
                <s:file name="kmlFile" label="KML File"/>
                <s:hidden name="landId"/>
                <s:submit value="%{getText('generate_geo_info.label')}" align="center"/>
            </s:form>
            <%-- <input value="Add" type="button" onclick="disp()">  --%>
        </td>
    </tr>
</table>
<s:form method="post">
    <table>
        <%--<tr>
            <td><s:label value="%{getText('referenceNumber.label')}"/></td>
            <td colspan="3"><s:textfield id="referenceNumber" cssClass="width-200-px" name="land.referenceNumber"
                                         readonly="true"/></td>
            <s:hidden id="kmlArea" name="land.kmlLandArea"/>
        </tr>--%>
        <tr>
            <s:hidden id="kmlArea" name="land.kmlLandArea"/>
            <td><s:label value="%{getText('geoParcelCode.label')}"/></td>
            <td colspan="3"><s:label  name="land.getGeoParcelCode()"
                                         /></td>
        </tr>
        <tr>
            <td><s:label value="%{getText('land_extent.label')}"/></td>
            <td colspan="3">
                <table class="width-100">
                    <tr>
                        <td><s:label value="%{getText('hectare.label')}"/></td>
                        <td colspan="5"><s:textfield id="kmlhectareId" name="kmlhectare" cssStyle="width: 80px;"
                                                     readonly="true"/></td>
                    </tr>
                    <tr>
                        <td><s:label value="%{getText('acre.label')}"/></td>
                        <td><s:textfield id="kmlacreId" name="kmlacre" cssStyle="width: 80px;" readonly="true"/></td>
                        <td><s:label value="%{getText('roods.label')}"/></td>
                        <td><s:textfield id="kmlroodsId" name="kmlroods" cssStyle="width: 80px;" readonly="true"/></td>
                        <td><s:label value="%{getText('perches.label')}"/></td>
                        <td><s:textfield id="kmlperchesId" name="kmlperches" cssStyle="width: 80px;"
                                         readonly="true"/></td>
                    </tr>

                </table>
            </td>
        </tr>
        <tr>
            <s:hidden name="land.kmlString"/>
            <s:hidden name="land.kmlMiddlePoint"/>

            <s:hidden name="landId"/>
            <td colspan="4">
                <s:submit value="%{getText('save.label')}" align="center" action="saveGISDataSubDivide" id="saveButton"/>
                <%--<s:submit value="%{getText('back.label')}" align="center" action="loadLandDetails"/>--%>
                <s:submit value="%{getText('exit.label')}" align="center" action="subDivideForm"/>
            </td>
        </tr>
    </table>
</s:form>
<table>
    <s:include value="map.jsp"/>
</table>